import {get_w_h} from './domFn';
import {SIZE} from './config';

const doc = document;
const slideBar = doc.getElementById('slide-bar');
const slideBarClose = slideBar.getElementsByClassName('icon-close')[0];
const phoneMenu = doc.getElementById('phone-menu');
const {desktop} = SIZE;
const fnClass = {
  show: () => {
    slideBar.classList.remove('hide')
    slideBar.classList.add('show')
  },
  hide: () => {
    slideBar.classList.add('hide')
    slideBar.classList.remove('show')
  }
}
slideBarClose.onclick = () => {
  fnClass.hide()
}
phoneMenu.onclick = () => {
  fnClass.show()
}
window.onresize = () => {
  const {width} = get_w_h(document.documentElement);
  width > desktop ? fnClass.show() : fnClass.hide()
}
